import http from '../core/request'
import { PageForm } from '../interface'
import { IGetCommon } from './common.type'


// 获取图片url module 没有传入默认参数
const getImageUrl = ({ module = 'NJG', entity, entityId }: IGetCommon.ReqParams) => {
  return http.get('/relationTableFile/list', { module, entity, entityId })
}
// 上传图片
const uploadImage = ({ group = 'JMS', file }: IGetCommon.ReqData) => {
  return http.upload<IGetCommon.ResData>('/file/oss/upload', { group, file })
}
//mis上传图片
const misUploadUrl = ({ path = 'jms', file,jobNumber }: IGetCommon.ReqData) => {
  return http.upload<IGetCommon.misResData>('/mis/file-upload', { path, file,jobNumber })
}
//千讯通上传图片
const qxtUploadUrl = ({ file }: IGetCommon.ReqData) => {
  return http.upload<IGetCommon.ResData>('/qxt/file-upload', { file })
}
// 操作日志
const getOperationLog = ({ module = 'NJG', entity, entityId }: IGetCommon.ReqParams) => {
  return http.get<IGetCommon.ResLog[]>('/business-log', { module, entity, entityId })
}
// 参数详情
const getParamsDetail = (params: IGetCommon.ReqParamsDetail) => {
  return http.get<IGetCommon.ResParams>('/parameter/key', params)
}

// 获取领导列表\
const getLeaderList = (params: PageForm) => {
  return http.get<IGetCommon.ResLeaderList>('/leader', params)
}
// 获取协议内容
const getAgreementContent = (params: IGetCommon.ReqAgreementContent) => {
  return http.get<IGetCommon.ResAgreementContent[]>('/agreement/list', params, {
    loading: false
  })
}
// 获取权限列表
const getPermissionList = () => {
  return http.get<IGetCommon.ResPermissionList[]>('/session/has_rules', {}, {
    loading: false
  })
}
// 获取字典列表-/dictionaries-data/list
const getDictionariesList = (params: IGetCommon.ReqDictionariesList) => {
  return http.get<IGetCommon.ResDictionariesList[]>('/dictionaries-data/list', params, {
    loading: false
  })
}
//从千迅通处获取字典
const getDictionariesQxtList = (params: IGetCommon.ReqDictionariesQxtList) => {
  return http.get('/qxt/dict-data/dict', params, {
    loading: false
  })
}

// 查询快递公司
const getLogisticsInfo = (params: IGetCommon.ReqLogisticsInfo) => {
  return http.get<IGetCommon.ResLogisticsInfo>('/express/auto-number', params, {
    loading: false
  })
}
// 日志列表
const getLogList = (params: IGetCommon.ReqLogList) => {
  return http.get<IGetCommon.ResLogList[]>('/business-log/list', params, {
    loading: false
  })
}
// 快递100查询
const getExpressInfo = (params: {
  num:string
}) => {
  return http.get<IGetCommon.ResExpressInfo>('/express', params, {
    loading: false
  })
}
export default {
  getImageUrl,
  uploadImage,
  misUploadUrl,
  qxtUploadUrl,
  getOperationLog,
  getParamsDetail,
  getLeaderList,
  getAgreementContent,
  getPermissionList,
  getDictionariesList,
  getDictionariesQxtList,
  getLogisticsInfo,
  getLogList,
  getExpressInfo
}